<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>数组的升序和降序</title>
	</head>
	<body>
		
		<p id="arrold"></p>
		
		<p>
			<input type="button" onclick="asc()" value="升序"/>
			<input type="button" onclick="desc()"value="降序" />
		</p>
		
		<p id="arrnew"></p>
		
		<script>
			var arr=[4,9,3,85,26];
			var old=document.getElementById("arrold");
			old.innerHTML=arr;
			
			var mynew=document.getElementById("arrnew");
			
			function asc () {
			    mynew.innerHTML=arr.sort(function(a,b){return a-b});
			}
			
			function desc () {	
			    mynew.innerHTML=arr.sort(function(a,b){return b-a});
			}
			
		</script>
	</body>
</html>
